package com.tianpengtech.front.mobile.moneylog;

import com.jfinal.plugin.activerecord.Page;
import com.tianpengtech.common.model.moneylog.MoneyLog;
import com.tianpengtech.common.util.XxxUtil;
import com.tianpengtech.front.mobile.common.util.R;

/**
 * Created by ggd on 2017/8/5 0005.
 */
public class MobileMoenyLogService {
    public static MobileMoenyLogService me = new MobileMoenyLogService();

    /**
     * 分页获取金钱日志
     * @return
     */
    public R list(int pageNum, int length,long uid){
        String select = "select * ";
        String sql = String.format(" from %s where %s=?  order by %s desc", MoneyLog.dao.tableName(),MoneyLog.WH_ID,MoneyLog.CREATE_TIME);
        Page<MoneyLog> page=MoneyLog.dao.paginate(pageNum,length,select,sql.toString(),uid);
        for (MoneyLog each : page.getList()) {
        	each.set(MoneyLog.DESCRIPTION, XxxUtil.handleContent(each.getStr(MoneyLog.DESCRIPTION), 25));
		}
        
        R r= R.ok();
        r.p("count",page.getTotalRow());
        r.p("pageNum",page.getPageNumber());
        r.p("totalPage",page.getTotalPage());
        r.p("list",page.getList());
        return r;
    }
}
